{include file="public/header" /}
<body>
<div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="">首页</a>
        <a href="">任务管理</a>
        <a href="">在制任务</a>
        <a>
          <cite>{$task_id}的生产记录</cite>
        </a>
      </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="{:url()}" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>

<div class="x-body" >
    <xblock>
        <a class="layui-btn"  target="_blank" href="{:url()}"><i class="iconfont">&#xe718;</i> 框架页面</a>
        <button class="layui-btn" id="addLog" onclick="x_admin_show('添加生产记录','{:url(\'index/ProductionRecords/addLog\',[\'task_id\'=>$task_id,\'drawing\'=>$drawing])}')"><i class="layui-icon"></i>添加生产记录</button>
        <span class="x-right" style="line-height:40px">共{$productLogCount}条 · 共{$productLogCount/25|getInt}页</span>
    </xblock>
    <div class="container-wrap">
        <div class="box-1">
            <table class="layui-table">
                <thead>
                <tr>
                    <!--<th>-->
                    <!--<div class="layui-unselect header layui-form-checkbox" lay-skin="primary"><i class="layui-icon">&#xe605;</i></div>-->
                    <!--</th>-->
                    <th>操作</th>
                    <!--<th>生产记录编号</th>-->
                    <th>序号</th>
                    <th>检验记录</th>
                    <th>品管</th>
                    <th>类型</th>
                    <th>操作者</th>
                    <th>数量</th>
                    <th>完成日期</th>
                    <th>设备</th>
                    <!--<th>任务编号</th>-->
                    <th>外协费用</th>
                    <th>外协单位</th>
                    <th>合格数</th>
                    <th>质量等级</th>
                    <th>检验员</th>
                    <th>互检人</th>
                    <th>品质放行</th>
                    <th>生产管理审核</th>
                    <th>备注</th>
                    <th>创建日期</th>
                    <th>创建人</th>
                    <th>修改日期</th>
                    <th>修改人</th>
                </tr>
                </thead>
                <tbody>
                {volist name="$productLog" id="list"}
                <tr>
                    <td class="td-manage">
                        <a title="修改" onclick="x_admin_show('修改 <span class=\'layui-badge layui-bg-blue\'>{$list.log_id}</span> 生产记录','{:url(\'index/ProductionRecords/edit\',[\'id\'=>$list.log_id,\'drawing\'=>$drawing,\'task_id\'=>$task_id])}')" href="javascript:;"><i style="color: green" class="layui-icon"></i></a>
                        <a title="删除" onclick="delete_(this,'{$list.log_id}')" href="javascript:void(0);" >
                            <i  style="color:red;" class="layui-icon"></i>
                        </a>
                    </td>
                    <td {$list.fulfill==0?'':'style="background:greenyellow"'}>{:substr($list['log_id'],-2)}</td>
                    <td>
                        <?php $ifczs = ifCz($list['process_id']);?>
                        {if $ifczs}
                        <a style="color: green" onclick="x_admin_show('<span class=\'layui-badge layui-bg-blue\'>{$list.log_id}</span> 的检验记录','{:url(\'index/TestRecord/viewIndex\',[\'task_id\'=>$list.log_id])}')" href="javascript:;">记录</a>
                        {else}
                        <a style="color: green" onclick="x_admin_show('<span class=\'layui-badge layui-bg-blue\'>{$list.log_id}</span> 的检验记录','{:url(\'index/TestRecord/viewIndex\',[\'task_id\'=>$list.log_id])}')" href="javascript:;">无</a>
                        {/if}
                    </td>
                    <td>
                        <?php $ifczs = ifPk($list['process_id']);?>
                        {if $ifczs}
                        <a style="color: green" onclick="x_admin_show('<span class=\'layui-badge layui-bg-blue\'>{$list.log_id}</span> 的品管','{:url(\'index/TestRecord/qualityShow\',[\'task_id\'=>$list.log_id])}',500)" href="javascript:;">品管</a>
                        {else}
                        <a style="color: green" onclick="x_admin_show('<span class=\'layui-badge layui-bg-blue\'>{$list.log_id}</span> 的品管','{:url(\'index/TestRecord/qualityShow\',[\'task_id\'=>$list.log_id])}',500)" href="javascript:;">无</a>
                        {/if}
                    </td>
                    <td>{$list.process_id|getGyType}</td>
                    <td>{$list.hr_id|getUserName}</td>
                    <td>{$list.complete_qty}</td>
                    <td>{$list.complete_date}</td>
                    <td>{$list.eqpmt_id}</td>
                    <!--<td>{$list.task_id}</td>-->
                    <td>{$list.cost}</td>
                    <td>{$list.costUnit}</td>
                    <td>{$list.product_qty}</td>
                    <td>{$list.quality_grade}</td>
                    <td>
                        {if $list.qc_inspector==""}
                        <a title="检验签字" onclick="sign_('{$list.log_id}','qc_inspector_date','qc_inspector')" href="javascript:void(0);" >
                            未签字
                        </a>
                        {else}
                        <a title="取消检验签字" onclick="signDown_('{$list.log_id}','qc_inspector_date','qc_inspector')" href="javascript:void(0);" >
                            {$list.qc_inspector} {$list.qc_inspector_date}
                        </a>
                        {/if}
                    </td>
                    <td>
                        {if $list.other_checker==""}
                        <a title="互检签字" onclick="sign_('{$list.log_id}','other_checker_date','other_checker')" href="javascript:void(0);" >
                            未签字
                        </a>
                        {else}
                        <a title="取消互检签字" onclick="signDown_('{$list.log_id}','other_checker_date','other_checker')" href="javascript:void(0);" >
                            {$list.other_checker} {$list.other_checker_date}
                        </a>
                        {/if}
                    </td>
                    <td>
                        {if $list.manege_name==""}
                        <a title="品质放行" onclick="sign_('{$list.log_id}','manege_date','manege_name')" href="javascript:void(0);" >
                            未签字
                        </a>
                        {else}
                        <a title="取消品质放行" onclick="signDown_('{$list.log_id}','manege_date','manege_name')" href="javascript:void(0);" >
                            {$list.manege_name} : {$list.manege_date}
                        </a>
                        {/if}
                    </td>
                    <td>{$list.if_audit}</td>
                    <td>{$list.remark}</td>
                    <td>{$list.create_time}</td>
                    <td>{$list.create_name}</td>
                    <td>{$list.update_time}</td>
                    <td>{$list.update_name}</td>
                </tr>
                {/volist}
                </tbody>
            </table>
        </div>
    </div>
    <!--___________________________________-->
    <div class="page">
        {$productLog|raw}
    </div>
    <script>
        /*删除*/
        function delete_(obj,id){
            layer.confirm('确认要删除吗？',function(index){
                var url = "{:url('index/ProductionRecords/delete')}";
                var postData ={"id":id};
                $.post(url,postData,function (result) {
                    if(result === 1 ){
                        $(obj).parents("tr").remove();
                        layer.msg('已删除!',{icon:1,time:1000});
                    }else {
                        layer.msg("删除失败", {icon:5,time:1000});
                    }
                },"json");
            });
        }

        //签字
        function sign_(where,dateKey,nameKey){
            layer.confirm("确定要签名吗？<br>姓名:{$Think.session.user.user_name}<br>日期:{:date('Y-m-d')}",function(index){
                var url = "{:url('index/ProductionRecords/sign')}";
                var postData ={"where":where,"dateKey":dateKey,"nameKey":nameKey};
                $.post(url,postData,function (result) {
                    if(result){
                        location.reload();
                        layer.msg('已签名!',{icon:1,time:1000});
                    }else {
                        location.reload();
                        layer.alert("签名失败", {icon: 5});
                    }
                },"json");
            });
        }
        //签字
        function signDown_(where,dateKey,nameKey){
            layer.confirm('确定取消签名吗？',function(index){
                var url = "{:url('index/ProductionRecords/signDown')}";
                var postData ={"where":where,"dateKey":dateKey,"nameKey":nameKey};
                $.post(url,postData,function (result) {
                    if(result){
                        location.reload();
                        layer.msg('已取消签名!',{icon:1,time:1000});
                    }else {
                        location.reload();
                        layer.alert("取消签名失败", {icon: 5});
                    }
                },"json");
            });
        }
        $(function () {
            $("#addLog").click(function () {
                layer.msg('正在加载中...', {time:500});
            })
        });

    </script>
</div>

</body>
</html>